package cn.appkf.flappybird.ui;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.MapLayer;
import com.badlogic.gdx.maps.MapObjects;
import com.badlogic.gdx.maps.objects.PolylineMapObject;
import com.badlogic.gdx.maps.tiled.TiledMap;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by Administrator on 2016/7/28.
 */
public class MyMap {


    TiledMap tiledMap;

    int mapBlockWidth;
    int mapBlockHeight;
    float mapWidth;
    float mapHeight;

    List<PolylineMapObject> dxs;

    OrthographicCamera cam;

    public void init(){
         mapBlockWidth= (int) this.tiledMap.getProperties().get("width");
         mapBlockHeight= (int) this.tiledMap.getProperties().get("height");
         mapWidth=mapBlockWidth*(int)this.tiledMap.getProperties().get("tilewidth");
         mapHeight=mapBlockHeight*(int)this.tiledMap.getProperties().get("tileheight");

        MapLayer ml=tiledMap.getLayers().get("地形");
        MapObjects mapLines=ml.getObjects();
        Iterator iterator= mapLines.iterator();

        this.dxs=new ArrayList<PolylineMapObject>();
        while (iterator.hasNext()){
            dxs.add((PolylineMapObject)iterator.next());
        }

    }


    public List<PolylineMapObject> getDxs() {
        return dxs;
    }

    public TiledMap getTiledMap() {
        return tiledMap;
    }

    public void setTiledMap(TiledMap tiledMap) {
        this.tiledMap = tiledMap;
    }

    public int getMapBlockWidth() {
        return mapBlockWidth;
    }

    public int getMapBlockHeight() {
        return mapBlockHeight;
    }

    public float getMapWidth() {
        return mapWidth;
    }

    public float getMapHeight() {
        return mapHeight;
    }

    public OrthographicCamera getCam() {
        return cam;
    }

    public void setCam(OrthographicCamera cam) {
        this.cam = cam;
    }
}
